{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "      采购\\n日期 新物料类别 原物料\\n类别 物料\\n描述  实际\\n采购  单价（含税/运/包）     金额  实采\\n差异\n",
      "0 2019-01-01   蔬菜类   叶菜类蔬菜   黄心白菜    50.0         1.6   80.0    0.00\n",
      "1 2019-01-01   蔬菜类   根茎类蔬菜    白萝卜    48.0         1.4   67.0   -0.28\n",
      "2 2019-01-01   蔬菜类   根茎类蔬菜    白洋葱     0.5         1.8    0.9   -0.13\n",
      "3 2019-01-01   蔬菜类   根茎类蔬菜   青梗菜花    80.0         5.2  416.0    1.41\n",
      "4 2019-01-01   蔬菜类    葱姜蒜类     大葱    23.0         3.0   69.0   -0.97\n",
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 2886 entries, 0 to 2885\n",
      "Data columns (total 8 columns):\n",
      "采购\n",
      "日期         2886 non-null datetime64[ns]\n",
      "新物料类别         2813 non-null object\n",
      "原物料\n",
      "类别        2813 non-null object\n",
      "物料\n",
      "描述         2813 non-null object\n",
      "实际\n",
      "采购         2241 non-null float64\n",
      "单价（含税/运/包）    2055 non-null float64\n",
      "金额            2497 non-null float64\n",
      "实采\n",
      "差异         2046 non-null float64\n",
      "dtypes: datetime64[ns](1), float64(4), object(3)\n",
      "memory usage: 180.5+ KB\n",
      "None\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:20: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  0%|                                                                                         | 0/2886 [00:00<?, ?it/s]E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:23: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "E:\\Anaconda\\lib\\site-packages\\IPython\\core\\interactiveshell.py:2963: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  exec(code_obj, self.user_global_ns, self.user_ns)\n",
      "  0%|▏                                                                                | 5/2886 [00:00<02:51, 16.81it/s]E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:25: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "100%|██████████████████████████████████████████████████████████████████████████████| 2886/2886 [02:09<00:00, 22.33it/s]\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:27: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  0%|                                                                                         | 0/2886 [00:00<?, ?it/s]E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:35: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  1%|▌                                                                               | 21/2886 [00:00<02:07, 22.49it/s]E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:33: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n",
      "  4%|██▊                                                                            | 105/2886 [00:04<02:03, 22.57it/s]E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:33: RuntimeWarning: invalid value encountered in double_scalars\n",
      "100%|██████████████████████████████████████████████████████████████████████████████| 2886/2886 [02:07<00:00, 22.16it/s]\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:39: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame.\n",
      "Try using .loc[row_indexer,col_indexer] = value instead\n",
      "\n",
      "See the caveats in the documentation: http://pandas.pydata.org/pandas-docs/stable/indexing.html#indexing-view-versus-copy\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "from pyecharts import Line,Grid,Bar,TreeMap\n",
    "import datetime\n",
    "from pandas.tseries.offsets import Day\n",
    "import pandas as pd\n",
    "\n",
    "path = r\"E:\\FMM\\2019\\2-13\\采购台账2019年1月份.xlsx\"\n",
    "# dataf= pd.read_excel(path,skiprows=1,sheetname = \"采购台账2019年1月份（呼家楼和东四）\")\n",
    "dataf= pd.read_excel(path,skiprows=1)\n",
    "df = dataf.iloc[:,[0,5,6,7,19,20,21,22]]\n",
    "print(df.head())\n",
    "print(df.info())\n",
    "# 数据处理规则\n",
    "# 新建列\n",
    "# 1.类别：if新物料类别=‘蔬菜类’：类别=新物料类别  else:类别=原物料类别\n",
    "# 2.单价:if单价=空 ：单价=金额/实际采购 else:单价=单价（含税/运/包） || if 单价！=数字：drop一行  \n",
    "# df['类别'] = na\n",
    "#添加类别列 \n",
    "from  tqdm import *\n",
    "df['类别'] = ''\n",
    "for i in tqdm(range(len(df))):\n",
    "    if df.iloc[i,1] == '蔬菜类':\n",
    "        df['类别'][i]  = df.iloc[i,1]\n",
    "    else:\n",
    "        df['类别'][i] = df.iloc[i,2]\n",
    "df.head()\n",
    "df['单价'] = ''\n",
    "\n",
    "#添加单价列\n",
    "for i in tqdm(range(len(df))):\n",
    "  \n",
    "    if pd.isnull(df.iloc[i,5]):\n",
    "        df['单价'][i]=df.iloc[i,6]/df.iloc[i,4]\n",
    "    else:\n",
    "        df['单价'][i] = df.iloc[i,5]\n",
    "        \n",
    "# 单价nan值删除\n",
    "# df['单价'].isnull().value_counts()\n",
    "df['单价']=df['单价'].fillna('999')\n",
    "slist = df[(df.单价=='999')].index.tolist()\n",
    "df = df.drop(slist)\n",
    "df['单价'] = df['单价'].astype(np.float64)\n",
    "df.dropna(axis = 0,how = 'any',inplace = True)#删除包含空值的行\n",
    "\n",
    "# ！截止到如此数据预处理基本完成 ，下面针对不同的图，提取处理不同的数据"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"f394c730df1b40a399dfc93947a77d1c\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_f394c730df1b40a399dfc93947a77d1c = echarts.init(document.getElementById('f394c730df1b40a399dfc93947a77d1c'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_f394c730df1b40a399dfc93947a77d1c = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u91c7\\u8d2d\\u91d1\\u989d\",\n",
       "            \"left\": \"55%\",\n",
       "            \"top\": \"3%\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 15\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 270835,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u91c7\\u8d2d\\u91d1\\u989d\",\n",
       "            \"symbol\": \"emptyCircle\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"smooth\": false,\n",
       "            \"step\": false,\n",
       "            \"showSymbol\": true,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2019-01-01\",\n",
       "                    57019.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-02\",\n",
       "                    42231.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-03\",\n",
       "                    23526.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-06\",\n",
       "                    62877.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-07\",\n",
       "                    28745.7\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-08\",\n",
       "                    37947.9\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-09\",\n",
       "                    20478.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-10\",\n",
       "                    38255.4\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-13\",\n",
       "                    99818.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-14\",\n",
       "                    27818.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-15\",\n",
       "                    25270.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-16\",\n",
       "                    25168.6\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-17\",\n",
       "                    33830.0\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-20\",\n",
       "                    56797.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-21\",\n",
       "                    26206.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-22\",\n",
       "                    29102.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-23\",\n",
       "                    26498.3\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-24\",\n",
       "                    18620.9\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-27\",\n",
       "                    58623.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-28\",\n",
       "                    24743.1\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-29\",\n",
       "                    22430.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-30\",\n",
       "                    25366.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-31\",\n",
       "                    52126.8\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"color\": \"#000\",\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"max\",\n",
       "                        \"name\": \"Maximum\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": \"40\",\n",
       "                        \"label\": {\n",
       "                            \"normal\": {\n",
       "                                \"textStyle\": {\n",
       "                                    \"color\": \"red\"\n",
       "                                }\n",
       "                            }\n",
       "                        }\n",
       "                    },\n",
       "                    {\n",
       "                        \"type\": \"min\",\n",
       "                        \"name\": \"Minimum\",\n",
       "                        \"symbol\": \"pin\",\n",
       "                        \"symbolSize\": \"40\",\n",
       "                        \"label\": {\n",
       "                            \"normal\": {\n",
       "                                \"textStyle\": {\n",
       "                                    \"color\": \"red\"\n",
       "                                }\n",
       "                            }\n",
       "                        }\n",
       "                    }\n",
       "                ]\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\",\n",
       "                        \"name\": \"mean-Value\"\n",
       "                    }\n",
       "                ],\n",
       "                \"symbolSize\": 10\n",
       "            },\n",
       "            \"seriesId\": 270835\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u91c7\\u8d2d\\u91d1\\u989d\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": false,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 90,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 8\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2019-01-01\",\n",
       "                \"2019-01-02\",\n",
       "                \"2019-01-03\",\n",
       "                \"2019-01-06\",\n",
       "                \"2019-01-07\",\n",
       "                \"2019-01-08\",\n",
       "                \"2019-01-09\",\n",
       "                \"2019-01-10\",\n",
       "                \"2019-01-13\",\n",
       "                \"2019-01-14\",\n",
       "                \"2019-01-15\",\n",
       "                \"2019-01-16\",\n",
       "                \"2019-01-17\",\n",
       "                \"2019-01-20\",\n",
       "                \"2019-01-21\",\n",
       "                \"2019-01-22\",\n",
       "                \"2019-01-23\",\n",
       "                \"2019-01-24\",\n",
       "                \"2019-01-27\",\n",
       "                \"2019-01-28\",\n",
       "                \"2019-01-29\",\n",
       "                \"2019-01-30\",\n",
       "                \"2019-01-31\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_f394c730df1b40a399dfc93947a77d1c.setOption(option_f394c730df1b40a399dfc93947a77d1c);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.line.Line at 0x1f48dfcda20>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 日实际采购数量/金额\n",
    "# from __future__ import unicode_literals\n",
    "from pyecharts import Grid\n",
    "from pyecharts import Bar, Line, Overlap\n",
    "\n",
    "\n",
    "data_sum = df.pivot_table(index=[\"采购\\n日期\"],values=[\"实际\\n采购\",\"金额\"],aggfunc='sum')\n",
    "data_sum.reset_index(inplace=True)\n",
    "# 保留两位小数\n",
    "decimals = pd.Series([1,0], index=['金额','实际\\n采购'])\n",
    "data_sum = data_sum.round(decimals)\n",
    "\n",
    "attr_sum = data_sum['采购\\n日期'].astype(str)#折线图的类别项不可以用datatime数据类型\n",
    "v6 = data_sum['实际\\n采购']\n",
    "v7 = data_sum['金额']\n",
    "bar_sum = Bar(title=\"采购数量\",title_text_size=15,title_pos=\"6%\",title_top=\"3%\")\n",
    "bar_sum.add(\"采购数量\", attr_sum, v6,\n",
    "            xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "            mark_point=[ \"max\", \"min\"],mark_point_textcolor=\"#000\" ,mark_point_symbolsize=\"40\",mark_point_textsize=3,\n",
    "            mark_line=[ \"average\"],\n",
    "            is_splitline_show=False,is_legend_show=False)\n",
    "\n",
    "line_jine = Line(\"采购金额\",title_text_size=15,title_pos=\"55%\",title_top=\"3%\")\n",
    "line_jine.add(\"采购金额\", attr_sum, v7,\n",
    "              xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "              is_lable_show=True,is_label_emphasis=True,\n",
    "              label_text_color =\"#000\",is_splitline_show=False,is_legend_show=False,\n",
    "              mark_point=[ \"max\", \"min\"],mark_point_textcolor=\"red\" ,mark_point_symbolsize=\"40\",mark_point_textsize=3,\n",
    "              mark_line=[ \"average\"],\n",
    "              )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"a9acefc2f4c644f6863ac8e6baaca039\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_a9acefc2f4c644f6863ac8e6baaca039 = echarts.init(document.getElementById('a9acefc2f4c644f6863ac8e6baaca039'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_a9acefc2f4c644f6863ac8e6baaca039 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u6bcf\\u65e5\\u7efc\\u5408\\u91c7\\u8d2d\\u5355\\u4ef7\",\n",
       "            \"left\": \"27%\",\n",
       "            \"top\": \"26%\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 15\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 3102152,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u732a\\u8089\\u7c7b\",\n",
       "            \"data\": [\n",
       "                37.4,\n",
       "                34.2,\n",
       "                32.5,\n",
       "                36.9,\n",
       "                31.5,\n",
       "                33.0,\n",
       "                46.0,\n",
       "                28.6,\n",
       "                60.2,\n",
       "                26.2,\n",
       "                29.6,\n",
       "                27.5,\n",
       "                24.3,\n",
       "                30.4,\n",
       "                29.7,\n",
       "                35.2,\n",
       "                28.7,\n",
       "                43.5,\n",
       "                30.8,\n",
       "                32.5,\n",
       "                21.2,\n",
       "                31.2,\n",
       "                30.1\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3102152\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u9e21\\u8089\\u7c7b\",\n",
       "            \"data\": [\n",
       "                52.6,\n",
       "                42.1,\n",
       "                NaN,\n",
       "                42.1,\n",
       "                21.1,\n",
       "                30.9,\n",
       "                73.8,\n",
       "                43.0,\n",
       "                51.5,\n",
       "                62.2,\n",
       "                47.3,\n",
       "                41.2,\n",
       "                41.6,\n",
       "                32.4,\n",
       "                38.6,\n",
       "                77.5,\n",
       "                31.8,\n",
       "                50.8,\n",
       "                29.7,\n",
       "                24.5,\n",
       "                61.2,\n",
       "                61.2,\n",
       "                21.0\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3102152\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u852c\\u83dc\\u7c7b\",\n",
       "            \"data\": [\n",
       "                7.7,\n",
       "                5.0,\n",
       "                6.5,\n",
       "                6.5,\n",
       "                5.1,\n",
       "                5.6,\n",
       "                5.9,\n",
       "                6.0,\n",
       "                9.4,\n",
       "                5.1,\n",
       "                6.5,\n",
       "                5.7,\n",
       "                6.7,\n",
       "                6.3,\n",
       "                6.4,\n",
       "                7.1,\n",
       "                7.5,\n",
       "                7.8,\n",
       "                8.5,\n",
       "                7.8,\n",
       "                7.0,\n",
       "                8.0,\n",
       "                7.4\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3102152\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u5e72\\u8d27\\u7c7b\",\n",
       "            \"data\": [\n",
       "                69.0,\n",
       "                NaN,\n",
       "                95.0,\n",
       "                80.6,\n",
       "                NaN,\n",
       "                76.0,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                102.6,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                64.6,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                77.3,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3102152\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"bar\",\n",
       "            \"name\": \"\\u51bb\\u8d27\\u7c7b\",\n",
       "            \"data\": [\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                21.2,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                14.8,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                12.8,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                12.8,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN,\n",
       "                NaN\n",
       "            ],\n",
       "            \"barCategoryGap\": \"20%\",\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 3102152\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u732a\\u8089\\u7c7b\",\n",
       "                \"\\u9e21\\u8089\\u7c7b\",\n",
       "                \"\\u852c\\u83dc\\u7c7b\",\n",
       "                \"\\u5e72\\u8d27\\u7c7b\",\n",
       "                \"\\u51bb\\u8d27\\u7c7b\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"68%\",\n",
       "            \"top\": \"28%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 90,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 8\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2019-01-01\",\n",
       "                \"2019-01-02\",\n",
       "                \"2019-01-03\",\n",
       "                \"2019-01-06\",\n",
       "                \"2019-01-07\",\n",
       "                \"2019-01-08\",\n",
       "                \"2019-01-09\",\n",
       "                \"2019-01-10\",\n",
       "                \"2019-01-13\",\n",
       "                \"2019-01-14\",\n",
       "                \"2019-01-15\",\n",
       "                \"2019-01-16\",\n",
       "                \"2019-01-17\",\n",
       "                \"2019-01-20\",\n",
       "                \"2019-01-21\",\n",
       "                \"2019-01-22\",\n",
       "                \"2019-01-23\",\n",
       "                \"2019-01-24\",\n",
       "                \"2019-01-27\",\n",
       "                \"2019-01-28\",\n",
       "                \"2019-01-29\",\n",
       "                \"2019-01-30\",\n",
       "                \"2019-01-31\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_a9acefc2f4c644f6863ac8e6baaca039.setOption(option_a9acefc2f4c644f6863ac8e6baaca039);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.bar.Bar at 0x1f48e366b38>"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 类别单价数据处理\n",
    "data_catgory_detail=df.pivot_table('单价',index='采购\\n日期',columns='类别',aggfunc='mean')\n",
    "data_catgory_detail.reset_index(inplace=True)\n",
    "data_catgory_detail\n",
    "# 保留两位小数\n",
    "decimals = pd.Series([1,1,1,1,1], index=['蔬菜类','猪肉类','干货类','冻货类','鸡肉类'])\n",
    "data_catgory_detail = data_catgory_detail.round(decimals)\n",
    "\n",
    "# 提取五大类单价数据\n",
    "attr = data_catgory_detail['采购\\n日期'].astype(str)\n",
    "\n",
    "v1 = data_catgory_detail['猪肉类']\n",
    "v2 = data_catgory_detail['鸡肉类']\n",
    "v3 = data_catgory_detail['蔬菜类']\n",
    "v4 = data_catgory_detail['干货类']\n",
    "v5 = data_catgory_detail['冻货类']\n",
    "\n",
    "# 每日综合采购单价图表绘制\n",
    "bar = Bar(\"每日综合采购单价\",title_text_size=15,title_pos=\"27%\",title_top=\"26%\")\n",
    "\n",
    "bar.add(\"猪肉类\", attr, v1, \n",
    "        is_splitline_show=False,axis_interval=0,xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "        legend_orient=\"vertical\",legend_pos=\"68%\",legend_top=\"28%\")\n",
    "bar.add(\"鸡肉类\", attr, v2, \n",
    "        is_splitline_show=False,axis_interval=0,xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "        legend_orient=\"vertical\",legend_pos=\"68%\",legend_top=\"28%\")\n",
    "bar.add(\"蔬菜类\", attr, v3, \n",
    "        axis_interval=0,xaxis_label_textsize =8,xaxis_rotate = 90,is_splitline_show=False,\n",
    "        legend_pos=\"68%\",legend_top=\"28%\",)\n",
    "bar.add(\"干货类\", attr, v4, \n",
    "        is_splitline_show=False,axis_interval=0,xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "        legend_orient=\"vertical\",legend_pos=\"68%\",legend_top=\"28%\")\n",
    "bar.add(\"冻货类\", attr, v5,\n",
    "        is_splitline_show=False,axis_interval=0,xaxis_label_textsize = 8,xaxis_rotate = 90,\n",
    "        legend_orient=\"vertical\",legend_pos=\"68%\",legend_top=\"28%\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"5d028f0adb754195af46e53642b9ca89\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_5d028f0adb754195af46e53642b9ca89 = echarts.init(document.getElementById('5d028f0adb754195af46e53642b9ca89'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_5d028f0adb754195af46e53642b9ca89 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u51bb\\u8d27\\u7c7b\",\n",
       "            \"left\": \"53%\",\n",
       "            \"top\": \"73%\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 15\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 1022877,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"symbol\": \"emptyCircle\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"smooth\": false,\n",
       "            \"step\": false,\n",
       "            \"showSymbol\": true,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2019-01-01\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-02\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-03\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-06\",\n",
       "                    21.2\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-07\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-08\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-09\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-10\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-13\",\n",
       "                    14.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-14\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-15\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-16\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-17\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-20\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-21\",\n",
       "                    12.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-22\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-23\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-24\",\n",
       "                    12.8\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-27\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-28\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-29\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-30\",\n",
       "                    NaN\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-31\",\n",
       "                    NaN\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"right\",\n",
       "                    \"textStyle\": {\n",
       "                        \"color\": \"red\",\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 1,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": [\n",
       "                    {\n",
       "                        \"type\": \"average\",\n",
       "                        \"name\": \"mean-Value\"\n",
       "                    }\n",
       "                ],\n",
       "                \"symbolSize\": 10\n",
       "            },\n",
       "            \"seriesId\": 1022877\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 8\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2019-01-01\",\n",
       "                \"2019-01-02\",\n",
       "                \"2019-01-03\",\n",
       "                \"2019-01-06\",\n",
       "                \"2019-01-07\",\n",
       "                \"2019-01-08\",\n",
       "                \"2019-01-09\",\n",
       "                \"2019-01-10\",\n",
       "                \"2019-01-13\",\n",
       "                \"2019-01-14\",\n",
       "                \"2019-01-15\",\n",
       "                \"2019-01-16\",\n",
       "                \"2019-01-17\",\n",
       "                \"2019-01-20\",\n",
       "                \"2019-01-21\",\n",
       "                \"2019-01-22\",\n",
       "                \"2019-01-23\",\n",
       "                \"2019-01-24\",\n",
       "                \"2019-01-27\",\n",
       "                \"2019-01-28\",\n",
       "                \"2019-01-29\",\n",
       "                \"2019-01-30\",\n",
       "                \"2019-01-31\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_5d028f0adb754195af46e53642b9ca89.setOption(option_5d028f0adb754195af46e53642b9ca89);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.line.Line at 0x1f48e366630>"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#猪肉类每日单价\n",
    "line_zhurou = Line(\"猪肉类\",title_top=\"46%\",title_pos=\"27.5%\",title_text_size=15)\n",
    "line_zhurou.add(\"\",attr,v1,\n",
    "                axis_interval =0,xaxis_label_textsize = 8,xaxis_rotate = 45,mark_point_symbolsize=\"40\",\n",
    "                mark_point=[ \"max\", \"min\"],mark_point_textcolor=\"white\" ,\n",
    "                mark_line=[ \"average\"],\n",
    "                is_splitline_show=False\n",
    "               )\n",
    "#鸡肉类每日单价图\n",
    "line_jirou = Line(\"鸡肉类\",title_top=\"46%\",title_pos=\"53%\",title_text_size=15)\n",
    "line_jirou.add(\"\",attr,v2,\n",
    "                axis_interval =0,xaxis_label_textsize = 8,xaxis_rotate = 45,mark_point_symbolsize=\"40\",\n",
    "                mark_point=[ \"max\", \"min\"],mark_point_textcolor=\"white\" ,\n",
    "                mark_line=[ \"average\"],\n",
    "                is_splitline_show=False\n",
    "               )\n",
    "# 蔬菜类每日单价图\n",
    "line_shucai = Line(\"蔬菜类\",title_top=\"73%\",title_pos=\"2.5%\",title_text_size=15)\n",
    "line_shucai.add(\"\",attr,v3,\n",
    "                axis_interval =0,xaxis_label_textsize = 8,xaxis_rotate = 45,\n",
    "                mark_point=[ \"max\", \"min\"],mark_point_textcolor=\"white\" ,mark_point_symbolsize=\"40\",mark_point_textsize=3,\n",
    "                mark_line=[ \"average\"],\n",
    "                is_splitline_show=False\n",
    "               )\n",
    "#干货类每日单价图\n",
    "line_ganhuo = Line(\"干货类\",title_top=\"73%\",title_pos='27.5%',title_text_size=15)\n",
    "line_ganhuo.add(\"\",attr,v4,\n",
    "                axis_interval =0,xaxis_label_textsize = 8,xaxis_rotate = 45,mark_point_symbolsize=\"40\",\n",
    "                is_label_show=True,label_text_color=\"green\",label_pos='right',\n",
    "                mark_line=[ \"average\"],\n",
    "                is_splitline_show=False\n",
    "               )\n",
    "# 冻货类每日单价图\n",
    "line_donghuo = Line(\"冻货类\",title_top=\"73%\",title_pos=\"53%\" ,title_text_size=15)\n",
    "line_donghuo.add(\"\",attr,v5,\n",
    "                axis_interval =0,xaxis_label_textsize = 8,xaxis_rotate = 45,mark_point_symbolsize=\"40\",\n",
    "                is_label_show=True,label_text_color=\"red\",label_pos='right',\n",
    "                mark_line=[ \"average\"],\n",
    "                is_splitline_show=False\n",
    "               )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"d8800a928af449459760bd379d723751\" style=\"width:800px;height:400px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_d8800a928af449459760bd379d723751 = echarts.init(document.getElementById('d8800a928af449459760bd379d723751'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_d8800a928af449459760bd379d723751 = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u5b9e\\u91c7\\u5dee\\u5f02\",\n",
       "            \"left\": \"2.5%\",\n",
       "            \"top\": \"46%\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 15\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 8542300,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"line\",\n",
       "            \"name\": \"\\u5b9e\\u91c7\\u5dee\\u5f02\",\n",
       "            \"symbol\": \"none\",\n",
       "            \"symbolSize\": 4,\n",
       "            \"smooth\": false,\n",
       "            \"step\": false,\n",
       "            \"showSymbol\": true,\n",
       "            \"data\": [\n",
       "                [\n",
       "                    \"2019-01-01\",\n",
       "                    159.3459999999999\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-02\",\n",
       "                    -157.82999999999998\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-03\",\n",
       "                    -108.63000000000005\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-06\",\n",
       "                    51.65833333299991\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-07\",\n",
       "                    -12.675000000000026\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-08\",\n",
       "                    -154.65\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-09\",\n",
       "                    -147.46500000000003\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-10\",\n",
       "                    245.79000000000002\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-13\",\n",
       "                    128.36899999999986\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-14\",\n",
       "                    -28.20000000000004\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-15\",\n",
       "                    -147.40999999999997\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-16\",\n",
       "                    55.150000000000034\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-17\",\n",
       "                    -55.64499999999997\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-20\",\n",
       "                    432.36000000000007\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-21\",\n",
       "                    -99.38000000000005\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-22\",\n",
       "                    43.5\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-23\",\n",
       "                    -229.66000000000008\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-24\",\n",
       "                    -201.5200000000001\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-27\",\n",
       "                    124.70500000000001\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-28\",\n",
       "                    -200.52000000000004\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-29\",\n",
       "                    -171.97500000000002\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-30\",\n",
       "                    -125.58999999999997\n",
       "                ],\n",
       "                [\n",
       "                    \"2019-01-31\",\n",
       "                    402.70000000000005\n",
       "                ]\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": false,\n",
       "                    \"position\": \"top\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    }\n",
       "                }\n",
       "            },\n",
       "            \"lineStyle\": {\n",
       "                \"normal\": {\n",
       "                    \"width\": 1,\n",
       "                    \"opacity\": 0.2,\n",
       "                    \"curveness\": 0,\n",
       "                    \"type\": \"solid\"\n",
       "                }\n",
       "            },\n",
       "            \"areaStyle\": {\n",
       "                \"opacity\": 0.4\n",
       "            },\n",
       "            \"markPoint\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"markLine\": {\n",
       "                \"data\": []\n",
       "            },\n",
       "            \"seriesId\": 8542300\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u5b9e\\u91c7\\u5dee\\u5f02\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": false,\n",
       "            \"left\": \"center\",\n",
       "            \"top\": \"top\",\n",
       "            \"orient\": \"horizontal\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"xAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"category\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"rotate\": 45,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 8\n",
       "                }\n",
       "            },\n",
       "            \"data\": [\n",
       "                \"2019-01-01\",\n",
       "                \"2019-01-02\",\n",
       "                \"2019-01-03\",\n",
       "                \"2019-01-06\",\n",
       "                \"2019-01-07\",\n",
       "                \"2019-01-08\",\n",
       "                \"2019-01-09\",\n",
       "                \"2019-01-10\",\n",
       "                \"2019-01-13\",\n",
       "                \"2019-01-14\",\n",
       "                \"2019-01-15\",\n",
       "                \"2019-01-16\",\n",
       "                \"2019-01-17\",\n",
       "                \"2019-01-20\",\n",
       "                \"2019-01-21\",\n",
       "                \"2019-01-22\",\n",
       "                \"2019-01-23\",\n",
       "                \"2019-01-24\",\n",
       "                \"2019-01-27\",\n",
       "                \"2019-01-28\",\n",
       "                \"2019-01-29\",\n",
       "                \"2019-01-30\",\n",
       "                \"2019-01-31\"\n",
       "            ]\n",
       "        }\n",
       "    ],\n",
       "    \"yAxis\": [\n",
       "        {\n",
       "            \"show\": true,\n",
       "            \"nameLocation\": \"middle\",\n",
       "            \"nameGap\": 25,\n",
       "            \"nameTextStyle\": {\n",
       "                \"fontSize\": 14\n",
       "            },\n",
       "            \"axisTick\": {\n",
       "                \"alignWithLabel\": false\n",
       "            },\n",
       "            \"inverse\": false,\n",
       "            \"boundaryGap\": true,\n",
       "            \"type\": \"value\",\n",
       "            \"splitLine\": {\n",
       "                \"show\": false\n",
       "            },\n",
       "            \"axisLine\": {\n",
       "                \"lineStyle\": {\n",
       "                    \"width\": 1\n",
       "                }\n",
       "            },\n",
       "            \"axisLabel\": {\n",
       "                \"interval\": \"auto\",\n",
       "                \"formatter\": \"{value} \",\n",
       "                \"rotate\": 0,\n",
       "                \"margin\": 8,\n",
       "                \"textStyle\": {\n",
       "                    \"fontSize\": 12\n",
       "                }\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_d8800a928af449459760bd379d723751.setOption(option_d8800a928af449459760bd379d723751);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.line.Line at 0x1f48b7d5a58>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 每日采购差异图表\n",
    "data_chayi = df.pivot_table(index=[\"采购\\n日期\"],values=[\"实采\\n差异\"],aggfunc='sum')#[]添加与否与很大差异\n",
    "data_chayi.reset_index(inplace=True)\n",
    "line_chayi = Line(\"实采差异\")\n",
    "attr_chayi = data_chayi[\"采购\\n日期\"].astype(\"str\") #折线图的X轴不能为时间datetime类型\n",
    "v8 = data_chayi['实采\\n差异']\n",
    "line_chayi = Line(\"实采差异\",title_text_size=15,title_top = \"46%\",title_pos=\"2.5%\")\n",
    "line_chayi.add(\n",
    "    \"实采差异\",attr_chayi,v8,is_fill=True,line_opacity=0.2,area_opacity=0.4,symbol=None,\n",
    "    xaxis_label_textsize = 8,xaxis_rotate = 45,is_splitline_show=False,is_legend_show=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:17: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:18: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:19: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:20: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n",
      "E:\\Anaconda\\lib\\site-packages\\ipykernel_launcher.py:21: DeprecationWarning: \n",
      ".ix is deprecated. Please use\n",
      ".loc for label based indexing or\n",
      ".iloc for positional indexing\n",
      "\n",
      "See the documentation here:\n",
      "http://pandas.pydata.org/pandas-docs/stable/indexing.html#ix-indexer-is-deprecated\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<script>\n",
       "    require.config({\n",
       "        paths: {\n",
       "            'echarts': '/nbextensions/echarts/echarts.min'\n",
       "        }\n",
       "    });\n",
       "</script>\n",
       "    <div id=\"3d06bcf5913142fea0e7afc20fb1851b\" style=\"width:800px;height:600px;\"></div>\n",
       "\n",
       "\n",
       "<script>\n",
       "    require(['echarts'], function(echarts) {\n",
       "        \n",
       "var myChart_3d06bcf5913142fea0e7afc20fb1851b = echarts.init(document.getElementById('3d06bcf5913142fea0e7afc20fb1851b'), 'light', {renderer: 'canvas'});\n",
       "\n",
       "var option_3d06bcf5913142fea0e7afc20fb1851b = {\n",
       "    \"title\": [\n",
       "        {\n",
       "            \"text\": \"\\u4e0a\\u54685\\u5927\\u7c7b\\u91c7\\u8d2d\\u91d1\\u989d\\u5360\\u6bd4\",\n",
       "            \"left\": \"75%\",\n",
       "            \"top\": \"26%\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 15\n",
       "            },\n",
       "            \"subtextStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"toolbox\": {\n",
       "        \"show\": true,\n",
       "        \"orient\": \"vertical\",\n",
       "        \"left\": \"95%\",\n",
       "        \"top\": \"center\",\n",
       "        \"feature\": {\n",
       "            \"saveAsImage\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"save as image\"\n",
       "            },\n",
       "            \"restore\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"restore\"\n",
       "            },\n",
       "            \"dataView\": {\n",
       "                \"show\": true,\n",
       "                \"title\": \"data view\"\n",
       "            }\n",
       "        }\n",
       "    },\n",
       "    \"series_id\": 7059473,\n",
       "    \"tooltip\": {\n",
       "        \"trigger\": \"item\",\n",
       "        \"triggerOn\": \"mousemove|click\",\n",
       "        \"axisPointer\": {\n",
       "            \"type\": \"line\"\n",
       "        },\n",
       "        \"textStyle\": {\n",
       "            \"fontSize\": 14\n",
       "        },\n",
       "        \"backgroundColor\": \"rgba(50,50,50,0.7)\",\n",
       "        \"borderColor\": \"#333\",\n",
       "        \"borderWidth\": 0\n",
       "    },\n",
       "    \"series\": [\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u661f\\u671f\\u4e00\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u852c\\u83dc\",\n",
       "                    \"value\": 5629.06\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u732a\\u8089\",\n",
       "                    \"value\": 5470.25\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9e21\\u8089\",\n",
       "                    \"value\": 6413.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u8d27\",\n",
       "                    \"value\": 1163.4\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u51bb\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"6%\",\n",
       "                \"13%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"85%\",\n",
       "                \"36%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 8\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7059473\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u661f\\u671f\\u4e8c\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u852c\\u83dc\",\n",
       "                    \"value\": 3535.7000000000003\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u732a\\u8089\",\n",
       "                    \"value\": 4260.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9e21\\u8089\",\n",
       "                    \"value\": 4956.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u51bb\\u8d27\",\n",
       "                    \"value\": 64.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"6%\",\n",
       "                \"13%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"85%\",\n",
       "                \"50%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 8\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7059473\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u661f\\u671f\\u4e09\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u852c\\u83dc\",\n",
       "                    \"value\": 5130.4\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u732a\\u8089\",\n",
       "                    \"value\": 5151.75\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9e21\\u8089\",\n",
       "                    \"value\": 6212.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u51bb\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"6%\",\n",
       "                \"13%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"85%\",\n",
       "                \"64%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 8\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7059473\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u661f\\u671f\\u56db\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u852c\\u83dc\",\n",
       "                    \"value\": 2968.92\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u732a\\u8089\",\n",
       "                    \"value\": 4488.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9e21\\u8089\",\n",
       "                    \"value\": 6200.1\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u51bb\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"6%\",\n",
       "                \"13%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"85%\",\n",
       "                \"78%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 8\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7059473\n",
       "        },\n",
       "        {\n",
       "            \"type\": \"pie\",\n",
       "            \"name\": \"\\u661f\\u671f\\u4e94\",\n",
       "            \"data\": [\n",
       "                {\n",
       "                    \"name\": \"\\u852c\\u83dc\",\n",
       "                    \"value\": 3918.9000000000005\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u732a\\u8089\",\n",
       "                    \"value\": -1425.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u9e21\\u8089\",\n",
       "                    \"value\": 7418.5\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u5e72\\u8d27\",\n",
       "                    \"value\": 0.0\n",
       "                },\n",
       "                {\n",
       "                    \"name\": \"\\u51bb\\u8d27\",\n",
       "                    \"value\": 346.14\n",
       "                }\n",
       "            ],\n",
       "            \"radius\": [\n",
       "                \"6%\",\n",
       "                \"13%\"\n",
       "            ],\n",
       "            \"center\": [\n",
       "                \"85%\",\n",
       "                \"92%\"\n",
       "            ],\n",
       "            \"label\": {\n",
       "                \"normal\": {\n",
       "                    \"show\": true,\n",
       "                    \"position\": \"inside\",\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 8\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                },\n",
       "                \"emphasis\": {\n",
       "                    \"show\": true,\n",
       "                    \"textStyle\": {\n",
       "                        \"fontSize\": 12\n",
       "                    },\n",
       "                    \"formatter\": \"{b}: {d}%\"\n",
       "                }\n",
       "            },\n",
       "            \"seriesId\": 7059473\n",
       "        }\n",
       "    ],\n",
       "    \"legend\": [\n",
       "        {\n",
       "            \"data\": [\n",
       "                \"\\u852c\\u83dc\",\n",
       "                \"\\u732a\\u8089\",\n",
       "                \"\\u9e21\\u8089\",\n",
       "                \"\\u5e72\\u8d27\",\n",
       "                \"\\u51bb\\u8d27\"\n",
       "            ],\n",
       "            \"selectedMode\": \"multiple\",\n",
       "            \"show\": true,\n",
       "            \"left\": \"91%\",\n",
       "            \"top\": \"56%\",\n",
       "            \"orient\": \"vertical\",\n",
       "            \"textStyle\": {\n",
       "                \"fontSize\": 12\n",
       "            }\n",
       "        }\n",
       "    ],\n",
       "    \"animation\": true,\n",
       "    \"color\": [\n",
       "        \"#c23531\",\n",
       "        \"#2f4554\",\n",
       "        \"#61a0a8\",\n",
       "        \"#d48265\",\n",
       "        \"#749f83\",\n",
       "        \"#ca8622\",\n",
       "        \"#bda29a\",\n",
       "        \"#6e7074\",\n",
       "        \"#546570\",\n",
       "        \"#c4ccd3\",\n",
       "        \"#f05b72\",\n",
       "        \"#ef5b9c\",\n",
       "        \"#f47920\",\n",
       "        \"#905a3d\",\n",
       "        \"#fab27b\",\n",
       "        \"#2a5caa\",\n",
       "        \"#444693\",\n",
       "        \"#726930\",\n",
       "        \"#b2d235\",\n",
       "        \"#6d8346\",\n",
       "        \"#ac6767\",\n",
       "        \"#1d953f\",\n",
       "        \"#6950a1\",\n",
       "        \"#918597\",\n",
       "        \"#f6f5ec\"\n",
       "    ]\n",
       "};\n",
       "myChart_3d06bcf5913142fea0e7afc20fb1851b.setOption(option_3d06bcf5913142fea0e7afc20fb1851b);\n",
       "\n",
       "    });\n",
       "</script>\n"
      ],
      "text/plain": [
       "<pyecharts.charts.pie.Pie at 0x1f48e2bedd8>"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "### 近前一周5大类的采购占比图\n",
    "data_sum_jine = df.pivot_table(index=[\"采购\\n日期\"],values=\"金额\",columns='类别',aggfunc='sum',fill_value=0)\n",
    "# data_sum_jine.reset_index(inplace=True)# 为了方便提取数据，采购日期仍为索引列\n",
    "data_sum_jine.head()\n",
    "# 获取距今为止前7日的数据，但由于做此图时的数据源为1月份的，为了方便取数据，只能-40+的天数\n",
    "# 由于今后是每周五更新，故可以直接取最后五日的数据，而不用这样重复迭代\n",
    "now_time =datetime.datetime.now()#获取当前时间\n",
    "yes_time5 = (now_time -117*Day()).strftime('%Y-%m-%d')\n",
    "yes_time4 = (now_time -118*Day()).strftime('%Y-%m-%d')\n",
    "yes_time3 = (now_time -119*Day()).strftime('%Y-%m-%d')\n",
    "yes_time2 = (now_time -120*Day()).strftime('%Y-%m-%d')\n",
    "yes_time1 = (now_time -121*Day()).strftime('%Y-%m-%d')\n",
    "yes_time1\n",
    "# 取5日5大类的每天的订购金额\n",
    "leibie = ['蔬菜类', '猪肉类', '鸡肉类','干货类', '冻货类' ]\n",
    "attr_time =['蔬菜', '猪肉', '鸡肉','干货', '冻货' ] \n",
    "v1_time = data_sum_jine.ix[yes_time1,leibie].tolist()#注意ix的用法，区别于iloc,loc的用法\n",
    "v2_time = data_sum_jine.ix[yes_time2,leibie].tolist()\n",
    "v3_time = data_sum_jine.ix[yes_time3,leibie].tolist()\n",
    "v4_time = data_sum_jine.ix[yes_time4,leibie].tolist()\n",
    "v5_time = data_sum_jine.ix[yes_time5,leibie].tolist()\n",
    "\n",
    "# 近一周5大类占比图绘制\n",
    "from pyecharts import Pie,Style\n",
    "pie = Pie('上周5大类采购金额占比', title_text_size=15,title_top=\"26%\" ,title_pos='75%',height=600)\n",
    "# 设置同一种风格\n",
    "style = Style()\n",
    "pie_style = style.add(label_pos=\"inside\",is_label_show=True,label_text_size=8,\n",
    "                      label_text_color=None,legend_orient=\"vertical\",legend_top = \"56%\",legend_pos=\"91%\")\n",
    "pie.add(\"星期一\", attr_time, v1_time, center=[85, 36], radius=[6, 13], **pie_style)\n",
    "pie.add(\"星期二\", attr_time, v2_time, center=[85, 50], radius=[6, 13], **pie_style)\n",
    "pie.add(\"星期三\", attr_time, v3_time, center=[85, 64], radius=[6, 13], **pie_style)\n",
    "pie.add(\"星期四\", attr_time, v4_time, center=[85, 78], radius=[6, 13], **pie_style)\n",
    "pie.add(\"星期五\", attr_time, v5_time, center=[85, 92], radius=[6, 13], **pie_style)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "phantomjs version: 2.1.1\n",
      "\n",
      "Generating file ...\n",
      "File saved in C:\\Users\\FMM\\FMMWorkFile\\采购监控模板.png\n"
     ]
    }
   ],
   "source": [
    "#合并显示\n",
    "from pyecharts import Grid\n",
    "\n",
    "grid = Grid(height=900,width=1050)\n",
    "\n",
    "# 第一行\n",
    "grid.add(bar_sum, grid_top=\"5%\",grid_bottom=\"80%\",grid_right=\"55%\",grid_left=\"6%\")\n",
    "grid.add(line_jine, grid_top=\"5%\",grid_bottom=\"80%\",grid_right=\"5%\",grid_left=\"55%\")\n",
    "# 第二行\n",
    "grid.add(bar, grid_top=\"28%\",grid_bottom=\"60%\",grid_right=\"33%\",grid_left=\"5%\")\n",
    "# 第三行\n",
    "grid.add(line_chayi, grid_top=\"49%\",grid_bottom=\"32%\",grid_right=\"77%\",grid_left=\"5%\")\n",
    "grid.add(line_zhurou, grid_top=\"49%\",grid_bottom=\"32%\",grid_right=\"51%\",grid_left=\"30%\",)\n",
    "grid.add(line_jirou, grid_top=\"49%\",grid_bottom=\"32%\",grid_right=\"27%\",grid_left=\"56%\")\n",
    "# 第四行\n",
    "grid.add(line_shucai, grid_top=\"76%\",grid_bottom=\"5%\",grid_right=\"78%\",grid_left=\"5%\")\n",
    "grid.add(line_ganhuo, grid_top=\"76%\",grid_bottom=\"5%\",grid_right=\"51%\",grid_left=\"30%\",)\n",
    "grid.add(line_donghuo, grid_top=\"76%\",grid_bottom=\"5%\",grid_right=\"27%\",grid_left=\"56%\",)\n",
    "\n",
    "grid.add(pie,grid_top = \"28%\",grid_bottom = \"5%\",grid_left = \"82%\",grid_right=\"1%\")\n",
    "\n",
    "grid.render('采购监控模板.png')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
